{% extends "layout.html" %}
{% from "macros/articles.html" import render_article %}
{% from "macros/categories.html" import render_category_details %}

{% block meta_title %}{{ this.name }} Category{% endblock %}
{% block meta_description %}{{ this.body.source }}{% endblock %}

{% block body %}
    {% set article = this.children.first() %}
    {% if article %}
        {{ render_category_details(this, show_articles=True, active_article=article._id) }}
        {{ render_article(article) }}
    {% else %}
        {{ render_category_details(this, show_articles=True) }}
    {% endif %}
{% endblock %}
